home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1998 May: Tool Chest / Dev.CD May 98 TC.toast / Tool Chest / Testing & Debugging / Hardware tools / HW Bring-up Tools / RW.c < prev    next >
Encoding:
C/C++ Source or Header  |  1993-09-17  |  1.1 KB  |  63 lines  |  [TEXT/MPS ]

  1. #include <Types.h>
  2. #include <StdIO.h>
  3.  
  4. #define numRdArgs    2        /* Number of arguments for read command.    */
  5. #define numWrArgs    3        /* Number of arguments for write command.    */
  6.  
  7. #define kCommandArg 0
  8. #define kAddrArg 1
  9. #define kDataArg 2
  10.  
  11. typedef unsigned long ulong ;
  12.  
  13. //
  14. // Main()
  15. //
  16. unsigned main(ulong argC, char *argV[])
  17.  
  18. {    
  19.     ulong    status = noErr;
  20.  
  21.     if ((argC >= 2) && (argC <= 3))
  22.     {    
  23.         ulong *address;
  24.     
  25.         sscanf(argV[kAddrArg],"%i", &address);
  26.         
  27.         if(true /*IN_RANGE(address, VBLInt, CurLine)*/)
  28.         {    
  29.             ulong writeValue, readValue ;
  30.         
  31.             switch(argC)
  32.             {    
  33.             case numRdArgs:
  34.                 readValue = *address ;
  35.                 
  36.                 fprintf(stdout,"$%p -> $%08X (%d)\n",
  37.                         address, readValue, readValue);
  38.             break;
  39.             
  40.             case numWrArgs:
  41.                 sscanf(argV[kDataArg],"%i",&writeValue);
  42.                 *address = writeValue ;
  43.                 fprintf(stdout,"$%p <- $%08X (%d)\n",
  44.                         address, writeValue, writeValue);
  45.             break;
  46.             
  47.             default:
  48.                 status++;
  49.             break;
  50.             }
  51.         }
  52.         else
  53.             status++;
  54.         }
  55.     else
  56.         status++;
  57.  
  58.     if (status != noErr)
  59.         fprintf(stdout,"# Usage %s - address [value].\n", argV[kCommandArg]);
  60.  
  61.     return(status);
  62. }
  63.